package com.smart.controller;

import com.smart.common.ResultVo;
import com.smart.entity.Chat;
import com.smart.entity.Feedback;
import com.smart.entity.Work;
import com.smart.service.ChatService;
import com.smart.service.FeedbackService;
import com.smart.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api")
public class UserWorkController {
    @Resource
    private WorkService workService;

    @Autowired
    ChatService chatService;

    @GetMapping("/user/work/list")
    public ResultVo UserWorkList(int tab) {
        List<Work> result = workService.UserWorkList(tab);
        return ResultVo.ok().data("item", result);
    }

    @GetMapping("/user/work/details")
    public ResultVo UserWorkDetails(String workId) {
        Work result = workService.UserWorkDetails(workId);
        return ResultVo.ok().data("item", result);
    }

    @PostMapping("/user/work/add")
    public ResultVo UserWorkAdd(Work work) {
        System.out.println(work);
        Integer result = workService.UserWorkAdd(work);
        return ResultVo.ok().data("item", result);
    }

    @GetMapping("/user/work/chat/all")
    public ResultVo UserWorkChatAll(Integer workId) {
        List<Chat> result = chatService.WorkChatAll(workId);
        return ResultVo.ok().data("item", result);
    }

    @PostMapping("/user/work/chat/add")
    public ResultVo UserWorkChatAdd( Chat chat) {
        Integer result = chatService.WorkChatAdd(chat);
        return ResultVo.ok().data("item", result);
    }
}
